package com.orphan.marketBack.service.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.orphan.marketBack.dao.MallUserdetail2Mapper;
import com.orphan.marketBack.po.MallUserdetail2;
import com.orphan.marketBack.po.dto.UsersManage;
import com.orphan.marketBack.service.IMallUserdetail2Service;
import com.orphan.marketBack.vo.UserVo;
import com.orphan.util.dto.UsersManageDto;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wanghaiyu
 * @since 2021-07-13
 */
@Service
public class MallUserdetail2ServiceImpl extends ServiceImpl<MallUserdetail2Mapper, MallUserdetail2> implements IMallUserdetail2Service {
@Autowired
MallUserdetail2Mapper Mapper;
  @Override
  public List<UsersManage> userAll() {
    List<UsersManage> usersManageDtos = Mapper.userAll();
    return usersManageDtos;
  }

  @Override
  public boolean updateUser(UsersManage user) {
    int i = Mapper.updateUser(user);
    return i>=0?true:false;
  }
  @Override
  public List<UserVo> selectUser(UserVo userVo) {
    return Mapper.UserSelect(userVo);
  }

  @RabbitListener(queues = "usersFreeze")
  public void getUserF(UsersManageDto usersManageDto){
    UsersManage manage =new UsersManage();

    BeanUtils.copyProperties(usersManageDto,manage);
    Mapper.updateUser(manage);

  }
}
